package com.li.springbootproject.service.rabbitmq;

import com.alibaba.fastjson.JSON;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;

/**
 * @author LiDong
 * @version 1.0.0
 * @createTime 8/16/2022 8:42 AM
 */
public class RabbitMqProduceConfirm implements RabbitTemplate.ConfirmCallback {

    private static final Logger logger = LoggerFactory.getLogger(RabbitMqProduceConfirm.class);

    @Override
    public void confirm(CorrelationData correlationData, boolean ack, String cause) {
        if (ack) {
            logger.info("ACK :{} ", JSON.toJSONString(correlationData));
        } else {
            logger.info("ACK error");
        }
    }
}
